﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SmartSpace.Core;
using SmartSapce.ServiceLocation;
using SmartSpace.UI.AspDotNet;

namespace AspDotNet.Shell
{
    public partial class _shell : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                Guid applicationId = new Guid(Request.QueryString["id"]);

                ICoreService service = ServiceLocator.Get<ICoreService>();
                Application application = service.GetApplication(applicationId);

                Theme theme = service.GetTheme(application.ThemeId);

                System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFile(Server.MapPath("~/" + theme.Package));

                ITheme themeInstance = (ITheme)assembly.CreateInstance(theme.Type);

                Control mycontrol = themeInstance.GetMainPanel(this).GetContentView();
                _ctlContainer.Controls.Add(mycontrol);
            }
            else
            {

            }
        }
    }
}